<template>
    <div class="main_content">
        <div class="scorll">
            <div class="content">
                <div class="search">
                    <div class="list">
                        <span>关键字搜索:</span>
                        <Input v-model="keyWord" placeholder="请输入设备编号" style="width: 200px"  maxlength="15" clearable />
                        <input type="password" autocomplete="new-password" style="display: none" />
                    </div>
                    <div class="list">
                        <span>硬件绑定:</span>
                        <Select v-model="bindFlag" style="width:200px;" placeholder="请选择" >
                            <Option v-for="item in bindFlagList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                        </Select>
                        <input type="password" autocomplete="new-password" style="display: none" />
                    </div>
                    <div class="list">
                        <span>在线状态:</span>
                        <Select v-model="netState" style="width:200px;" placeholder="请选择" >
                            <Option v-for="item in netStateList" :value="item.id" :key="item.id">{{ item.name }}</Option>
                        </Select>
                        <input type="password" autocomplete="new-password" style="display: none" />
                    </div>
                    <div class="list">
                        <el-button type="primary" @click="searchAll" size="small" plain>搜索</el-button>
                        <el-button type="info" @click="clear" style="margin-left:20px;" size="small" plain>重置</el-button>
                    </div>
                </div>
                <div class="search" style="margin-top: 20px;">
                    <el-button v-if="btnList.includes('fse/crane/device/add')" type="primary" @click="updateRow(0)" size="small" plain>添加塔机</el-button>
                </div>
                <div class="table">
                    <el-table :data="list" style="width: 100%" :stripe='true'>
                        <el-table-column fixed prop="code" label="设备编号"></el-table-column>
                        <el-table-column prop="modelName" label="设备型号"></el-table-column>
                        <el-table-column prop="bindFlag" label="设备绑定">
                            <template slot-scope="scope">
                                <div v-if="scope.row.bindFlag == 0">
                                    <span style="color:#A9B0BB">未绑定</span>
                                </div>
                                <div v-if="scope.row.bindFlag == 1">
                                    <span style="color:#28D79C">已绑定</span>
                                </div>
                            </template>
                        </el-table-column>
                        <el-table-column prop="netState" label="在线状态">
                            <template slot-scope="scope">
                                <el-tag type="info" v-if="scope.row.netState == 0 && scope.row.bindFlag == 1" size="small">离线</el-tag>
                                <el-tag type="success" v-else-if="scope.row.netState == 1 && scope.row.bindFlag == 1" size="small">在线</el-tag>
                                <span v-else >-</span>
                            </template>
                        </el-table-column>
                        <el-table-column prop="operatorName" label="操作手"></el-table-column>
                        <el-table-column fixed="right" label="操作" width="300" align="center">
                            <template slot-scope="scope">
                                <el-button @click.native.prevent="getDetails(scope.$index, list,1)" :disabled="!btnList.includes('fse/crane/device/edit')" type="text" size="small"  >详情</el-button>
                                <el-button style="color:red" @click.native.prevent="remove(scope.$index, list)" :disabled="!btnList.includes('fse/crane/device/del')" type="text" size="small">删除</el-button>
                            </template>
                        </el-table-column>
                    </el-table>
                </div>
                <div class="clearfix"  >
                    <div class="float-right">
                        <Page v-if="totalCount" style="margin: 20px 0;text-align: center;" :current.sync="current" :total="totalCount" :page-size="pageSize" show-elevator show-total @on-change="pageChange"></Page>
                    </div>
                </div>
            </div>
        </div>
        <Modal v-model="updateModal" title="添加塔机" :mask-closable="false" width="1000px">
            <div class="msg" style="margin-top:15px">
                <h2>
                    <em></em>
                    <span>基本信息</span>
                </h2>
                <div class="list">
                    <div class="item">
                        <span class="tip">*</span>
                        <span>设备编号:</span>
                        <Input v-model="code" placeholder="请输入设备编号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                    </div>
                    <div class="item">
                        <span>设备型号:</span>
                        <Input v-model="model" placeholder="请输入设备编号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                    </div>
                </div>
                <div class="list">
                    <div class="item">
                        <span>制造单位:</span>
                        <Input v-model="manufacturer" placeholder="请输入制造单位" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                    </div>
                    <div class="item">
                        <span>出厂编号:</span>
                        <Input v-model="deliveryCode" placeholder="请输入出厂编号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                    </div>
                </div>
                <div class="list">
                    <div class="item">
                        <span>出厂日期:</span>
                        <DatePicker type="date" placeholder="请选择出厂日期" style="width: 300px" format="yyyy-MM-dd"  v-model="deliveryDate" :clearable="false"></DatePicker>
                    </div>
                    <div class="item">
                        <span>安拆单位:</span>
                        <Input v-model="installUnit" placeholder="请输入安拆单位" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                    </div>
                </div>
                <h2>
                    <em></em>
                    <span>其他信息</span>
                </h2>
                <div class="list">
                    <div class="item">
                        <span>产权单位:</span>
                        <Input v-model="propertyUnit" placeholder="请输入产权单位" :maxlength="length"  show-word-limit  style="width: 300px" clearable />
                    </div>
                    <div class="item">
                        <span>监测证号:</span>
                        <Input v-model="monitorNo" placeholder="请输入监测证号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                    </div>
                </div>
                <div class="list">
                    <div class="item">
                        <span>备案编号:</span>
                        <Input v-model="fileNo" placeholder="请输入备案编号" style="width: 300px" clearable />
                    </div>
                    <div class="item">
                        <span>备案日期:</span>
                        <DatePicker type="date" placeholder="请选择备案日期" style="width: 300px" format="yyyy-MM-dd"  v-model="fileDate" :clearable="false"></DatePicker>
                    </div>
                </div>
                <h2 style="margin-top:20px">
                    <em></em>
                    <span>操作手</span>
                    <i class="el-icon-circle-plus-outline add" style="font-size:24px;cursor: pointer"  @click="addEmp" v-show="operatorList.length!==3"></i>
                </h2>
                <div class="operEmpList" v-if="operatorList.length>0">
                    <div class="item" v-for="( item ,index ) in operatorList" :key="index">
                        <div class="item_close"  @click="removeEmp(index, operatorList)">
                            <Icon type="ios-close-circle" style="color:var(--themeColor);font-size:20px;"/>
                        </div>
                        <div class="item_emp">
                            <span>姓 名:</span>
                            <Input v-model="item.name" placeholder="请输入" style="width: 200px;" clearable />
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <div class="item_emp">
                            <span>电 话:</span>
                            <Input v-model="item.phone" placeholder="请输入" style="width: 200px;" clearable />
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                        <div class="item_emp">
                            <span>证件号:</span>
                            <Input v-model="item.cert" placeholder="请输入" style="width: 200px;" clearable />
                            <input type="password" autocomplete="new-password" style="display: none" />
                        </div>
                    </div>
                </div>
                <div class="none_data" v-else style="width:98%;height:150px;margin:auto;text-align:center;line-height:150px;font-size:20px;">暂无数据</div>
            </div>
            <div slot="footer">
                <el-button @click="cancel(0)" type="type" size="small" plain>取消</el-button>
                <el-button @click="submitAll" type="primary" size="small" plain v-preventReClick="1500">保存</el-button>
            </div>
        </Modal>
        <Modal v-model="deleteModal" title="删除" width="360px;" :mask-closable="false">
            <div style="margin:10px;padding:16px;">确定要删除这条数据吗？</div>
            <div slot="footer">
                <el-button @click="cancel(1)" type="info" size="small" plain>取消</el-button>
                <el-button @click="deteleRow" type="primary" size="small" plain v-preventReClick="1500">确定</el-button>
            </div>
        </Modal>
        <Modal v-model="unbindModal" title="解绑设备" width="360px;" :mask-closable="false">
            <div style="margin:10px;padding:16px;">确定要解绑这台设备？</div>
            <div slot="footer">
                <el-button @click="cancel(3)" type="info" size="small" plain>取消</el-button>
                <el-button @click="unbind" type="primary" size="small" plain v-preventReClick="1500">确定</el-button>
            </div>
        </Modal>
        <Modal v-model="detailsModal" :title="isAdd?'塔机详情':'塔机编辑'" width="1000px;" :mask-closable="false" >
            <Tabs v-model="detailActiveName" @on-click="setTab">
                <TabPane label="设备信息" name="1">
                    <div class="msg" v-if="isAdd">
                        <h2>
                            <em></em>
                            <span>基本信息</span>
                            <i class="el-icon-edit-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="edit_btn"></i>
                        </h2>
                        <div class="list">
                            <div class="item">
                                <span>设备编号:</span>
                                <span>{{details.code}}</span>
                            </div>
                            <div class="item">
                                <span>设备型号:</span>
                                <span>{{details.modelName || '-'}} </span>
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <span>制造单位:</span>
                                <span>{{details.manufacturer || '-'}} </span>
                            </div>
                            <div class="item">
                                <span>出厂编号:</span>
                                <span>{{details.deliveryCode || '-'}} </span>
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <span>出厂日期:</span>
                                <span>{{details.deliveryDate || '-'}} </span>
                            </div>
                            <div class="item">
                                <span>安拆单位:</span>
                                <span>{{details.installUnit || '-'}} </span>
                            </div>
                        </div>
                        <h2>
                            <em></em>
                            <span>其他信息</span>
                        </h2>
                        <div class="list">
                            <div class="item">
                                <span>产权单位:</span>
                                <span>{{details.propertyUnit || '-'}} </span>
                            </div>
                            <div class="item">
                                <span>监测证号:</span>
                                <span>{{details.monitorNo || '-'}} </span>
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <span>备案编号:</span>
                                <span>{{details.fileNo || '-'}} </span>
                            </div>
                            <div class="item">
                                <span>备案日期:</span>
                                <span>{{details.fileDate || '-'}} </span>
                            </div>
                        </div>
                        <h2>
                            <em></em>
                            <span>操作手信息</span>
                        </h2>
                        <div class="operatorList" v-if="details.operatorList.length>0">
                            <div class="item" v-for="(item , index) in details.operatorList" :key="index">
                                <div class="img">
                                    <img :src="peoImg" alt="" style="width:100%;height:100%">
                                </div>
                                <div class="operEmpInfo">
                                    <div class="itemInfo">
                                        <span>姓名</span>
                                        <span>{{item.name ? item.name :'—'}}</span>
                                    </div>
                                    <div class="itemInfo">
                                        <span>电话</span>
                                        <span>{{item.phone ? item.phone :'—'}}</span>
                                    </div>
                                    <div class="itemInfo">
                                        <span>证件</span>
                                        <span>{{item.cert ? item.cert :'—'}}</span>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="none_data" v-else style="width:98%;height:150px;margin:auto;text-align:center;line-height:150px;font-size:20px;">暂无数据</div>
                    </div>
                    <div class="msg" v-if="!isAdd">
                        <h2>
                            <em></em>
                            <span>基本信息</span>
                        </h2>
                        <div class="list">
                            <div class="item">
                                <span class="tip">*</span>
                                <span>设备编号:</span>
                                <Input v-model="code" placeholder="请输入设备编号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                            </div>
                            <div class="item">
                                <span>设备型号:</span>
                                <Input v-model="model" placeholder="请输入设备编号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <span>制造单位:</span>
                                <Input v-model="manufacturer" placeholder="请输入制造单位" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                            </div>
                            <div class="item">
                                <span>出厂编号:</span>
                                <Input v-model="deliveryCode" placeholder="请输入出厂编号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <span>出厂日期:</span>
                                <DatePicker type="date" placeholder="请选择出厂日期" @on-change="changeData" style="width: 300px" format="yyyy-MM-dd"  v-model="deliveryDate" :clearable="false"></DatePicker>
                            </div>
                            <div class="item">
                                <span>安拆单位:</span>
                                <Input v-model="installUnit" placeholder="请输入安拆单位" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                            </div>
                        </div>
                        <h2>
                            <em></em>
                            <span>其他信息</span>
                        </h2>
                        <div class="list">
                            <div class="item">
                                <span>产权单位:</span>
                                <Input v-model="propertyUnit" placeholder="请输入产权单位" :maxlength="length"  show-word-limit  style="width: 300px" clearable />
                            </div>
                            <div class="item">
                                <span>监测证号:</span>
                                <Input v-model="monitorNo" placeholder="请输入监测证号" :maxlength="length" show-word-limit  style="width: 300px" clearable />
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <span>备案编号:</span>
                                <Input v-model="fileNo" placeholder="请输入备案编号" style="width: 300px" clearable />
                            </div>
                            <div class="item">
                                <span>备案日期:</span>
                                <DatePicker type="date" placeholder="请选择备案日期" @on-change="changeTime" style="width: 300px" format="yyyy-MM-dd"  v-model="fileDate" :clearable="false"></DatePicker>
                            </div>
                        </div>
                        <h2 style="margin-top:20px">
                            <em></em>
                            <span>操作手</span>
                            <i class="el-icon-circle-plus-outline add" style="font-size:24px;cursor: pointer"  @click="addEmp" v-show="operatorList.length!==3"></i>
                        </h2>
                        <div class="operEmpList" v-if="operatorList.length>0">
                            <div class="item" v-for="( item ,index ) in operatorList" :key="index">
                                <div class="item_close"  @click="removeEmp(index, operatorList)">
                                    <Icon type="ios-close-circle" style="color:var(--themeColor);font-size:20px;"/>
                                </div>
                                <div class="item_emp">
                                    <span>姓 名:</span>
                                    <Input v-model="item.name" placeholder="请输入" style="width: 200px;" clearable />
                                    <input type="password" autocomplete="new-password" style="display: none" />
                                </div>
                                <div class="item_emp">
                                    <span>电 话:</span>
                                    <Input v-model="item.phone" placeholder="请输入" style="width: 200px;" clearable />
                                    <input type="password" autocomplete="new-password" style="display: none" />
                                </div>
                                <div class="item_emp">
                                    <span>证件号:</span>
                                    <Input v-model="item.cert" placeholder="请输入" style="width: 200px;" clearable />
                                    <input type="password" autocomplete="new-password" style="display: none" />
                                </div>
                            </div>
                        </div>
                        <div class="none_data" v-else style="width:98%;height:150px;margin:auto;text-align:center;line-height:150px;font-size:20px;">暂无数据</div>
                    </div>
                </TabPane>
                <TabPane label="塔机监测" name="2">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>硬件信息</span>
                        </h2>
                        <div class="list">
                            <div class="item">
                                <span style="width:70px;white-space:nowrap">硬件SN：</span>
                                <span style="width:250px;margin:0px 25px" v-if="snFlag == 1 || snFlag == 3">{{sn}}</span>
                                <span style="width:250px" v-if="snFlag == 1 || snFlag == 3">{{platformText}}</span>
                                <Input  v-model="bound_sn" placeholder="请输入硬件SN码" style="width:250px;margin:0px 10px" v-if="snFlag == 2" clearable />
                                <el-button type="primary" size="small" plain v-if="snFlag == 1" @click="boundRow">绑定</el-button>
                                <Select v-model="platform" style="width:250px;margin-right:10px;" placeholder="请选择平台" v-if="snFlag == 2">
                                    <Option v-for="item in platformList" :value="item.platform" :key="item.platform">{{ item.name }}</Option>
                                </Select>
                                <el-button type="primary" size="small" plain v-if="snFlag == 2" @click="boundSumbit" >确定</el-button>
                                <el-button type="info" size="small" plain @click="cancel(5)" v-if="snFlag == 2" >取消</el-button>
                                <el-button type="primary" size="small" plain v-if="snFlag == 3" @click="unbindRow">解绑</el-button>
                            </div>
                        </div>
                        <h2>
                            <em></em>
                            <span>硬件状态</span>
                        </h2>
                        <div class="list">
                            <div class="item">
                                <span>在线状态:</span>
                                <span v-if="details.netState == 0 &&snFlag == 3">离线</span>
                                <span v-else-if="details.netState == 1 &&snFlag == 3">在线</span>
                                <span v-else>-</span>
                            </div>
                        </div>
                    </div>
                </TabPane>
                <TabPane label="塔机视频" name="3">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>视频信息</span>
                            <i class="el-icon-edit-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="editFvs" v-if="!fvsFlag"></i>
                        </h2>
                        <div class="list" v-for="(item,index) in craneTypeList" :key="index">
                            <div class="item">
                                <span>{{item.name}}:</span>
                                <span v-if="!fvsFlag" style="flex:1">{{item.fvsDeviceName}}</span>
                                <Cascader :data="fvsList" v-model="item.type" filterable trigger="hover" placeholder="请选择摄像头" style="width:250px;" v-if="fvsFlag"></Cascader>
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <el-button @click="cancel(6)" type="type" size="small" plain v-if="fvsFlag">取消</el-button>
                                <el-button @click="submitFvs" type="primary" size="small" plain v-preventReClick="1500" v-if="fvsFlag">保存</el-button>
                            </div>
                        </div>
                    </div>
                </TabPane>
                <TabPane label="机械设备安装" name="4">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>机械设备安装信息</span>
                            <i class="el-icon-edit-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="editFvs" v-if="!fvsFlag"></i>
                        </h2>
                        <div class="list" >
                            <div class="item">
                                <span>安装名称:</span>
                                <span v-if="!fvsFlag" style="flex:1">{{device_install.name ? device_install.name : '—'}}</span>
                                <Input v-if="fvsFlag" v-model="submit_device_install.name" placeholder="请输入安装名称" :maxlength="32" show-word-limit  style="width: 250px" clearable />
                            </div>
                        </div>
                        <div class="list" >
                            <div class="item">
                                <span>安装部位:</span>
                                <span v-if="!fvsFlag" style="flex:1">{{device_install.part ? device_install.part : '—'}}</span>
                                <Input v-if="fvsFlag" v-model="submit_device_install.part" placeholder="请输入安装部位" :maxlength="32" show-word-limit  style="width: 250px" clearable />
                            </div>
                        </div>
                        <div class="list" >
                            <div class="item">
                                <span>安装时间:</span>
                                <span v-if="!fvsFlag" style="flex:1">{{device_install.startTime ? device_install.startTime : '—'}}</span>
                                <DatePicker v-if="fvsFlag" :options="options" type="date" placeholder="请选择安装时间" style="width: 250px" format="yyyy-MM-dd"  v-model="submit_device_install.startTime" :clearable="false"></DatePicker>
                            </div>
                        </div>
                        <div class="list" v-if="!fvsFlag">
                            <div class="item" style="width: 100%;align-items: flex-start">
                                <span>安装图片:</span>
                                <template v-if="device_install.attachUrl.length > 0">
                                    <div class="list uploadList" style="padding:0;">
                                        <div class="item" v-for="(item , index) in device_install.attachUrl"  :key="index" style="margin-left: 0;">
                                            <span>
                                                <el-image class="avatar" :src="item" :preview-src-list="[item]" v-if="imgList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-word.png" :preview-src-list="['./../../assets/images/fse/common/file-word.png']" v-else-if="wordList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-excel.png" :preview-src-list="['./../../assets/images/fse/common/file-excel.png']" v-else-if="excelList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-ppt.png" :preview-src-list="['./../../assets/images/fse/common/file-ppt.png']" v-else-if="pptList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-pdf.png" :preview-src-list="['./../../assets/images/fse/common/file-pdf.png']" v-else-if="pdfList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-video.png" :preview-src-list="['./../../assets/images/fse/common/file-video.png']" v-else-if="videoList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-audio.png" :preview-src-list="['./../../assets/images/fse/common/file-audio.png']" v-else-if="audioList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-zip.png" :preview-src-list="['./../../assets/images/fse/common/file-zip.png']" v-else-if="zipList.includes(extname(item))"></el-image>
                                                <el-image class="avatar" src="./../../assets/images/fse/common/file-txt.png" :preview-src-list="['./../../assets/images/fse/common/file-txt.png']" v-else-if="txtList.includes(extname(item))"></el-image>
                                                <el-button @click="download(item, 1)" size="mini" type="primary">下载</el-button>
                                            </span>
                                            <!-- <span>{{item}}</span> -->
                                        </div>
                                    </div>
                                </template>
                                <template v-else>
                                    <span>—</span>
                                </template>
                            </div>
                        </div>
                        <div class="list" v-if="fvsFlag">
                            <div class="item upload" style="width: 100%;">
                                <span>安装图片:</span>
                                <el-upload
                                    :headers="headers"
                                    :action="$axios.defaults.baseURL+'/ms/api/resume/upload'"
                                    :show-file-list="false"
                                    :on-success="uploadSuccess"
                                    :accept="acceptObj"
                                    :before-upload="beforeAvatarUpload">
                                    <el-button type="primary" size="small" plain>上传文件</el-button>
                                </el-upload>
                                <span style="flex: 1;margin-left: 15px;">可上传最大为 2.0 MB 文件。如果文件比较大请先压缩文件</span>
                            </div>
                        </div>
                        <div class="list uploadList" v-if="fvsFlag">
                            <div class="item" v-for="(item , index) in submit_device_install.attachUrl"  :key="index">
                                <span>
                                    <el-image class="avatar" :src="item" :preview-src-list="[item]" v-if="imgList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-word.png" :preview-src-list="['./../../assets/images/fse/common/file-word.png']" v-else-if="wordList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-excel.png" :preview-src-list="['./../../assets/images/fse/common/file-excel.png']" v-else-if="excelList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-ppt.png" :preview-src-list="['./../../assets/images/fse/common/file-ppt.png']" v-else-if="pptList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-pdf.png" :preview-src-list="['./../../assets/images/fse/common/file-pdf.png']" v-else-if="pdfList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-video.png" :preview-src-list="['./../../assets/images/fse/common/file-video.png']" v-else-if="videoList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-audio.png" :preview-src-list="['./../../assets/images/fse/common/file-audio.png']" v-else-if="audioList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-zip.png" :preview-src-list="['./../../assets/images/fse/common/file-zip.png']" v-else-if="zipList.includes(extname(item))"></el-image>
                                    <el-image class="avatar" src="./../../assets/images/fse/common/file-txt.png" :preview-src-list="['./../../assets/images/fse/common/file-txt.png']" v-else-if="txtList.includes(extname(item))"></el-image>
                                </span>
                                <div class="close" @click="delFile(index)"><img src="../../assets/images/fse/common/rule_del.png" alt=""></div>
                            </div>
                        </div>
                        <div class="list">
                            <div class="item">
                                <el-button @click="cancel(10)" type="type" size="small" plain v-if="fvsFlag">取消</el-button>
                                <el-button @click="save(1)" type="primary" size="small" plain v-preventReClick="1500" v-if="fvsFlag">保存</el-button>
                            </div>
                        </div>
                    </div>
                </TabPane>
                <TabPane label="机械设备检查" name="5">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>机械设备检查信息</span>
                            <i  class="el-icon-circle-plus-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="setCommonFlag(2)"></i>
                        </h2>
                        <div class="table" style="width:96%;margin:20px auto;">
                            <el-table :data="tableList" style="width: 100%" :stripe='true' >
                                <el-table-column prop="name" label="检查名称" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.name ? scope.row.name : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.name ? scope.row.name : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="part" label="检查部位" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.part ? scope.row.part : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.part ? scope.row.part : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="startTime" label="检查时间" align="center"></el-table-column>
                                <el-table-column prop="state" label="状态" align="center">
                                    <template slot-scope="scope">
                                        {{scope.row.state == 1 ? '正常' : '异常'}}
                                    </template>
                                </el-table-column>
                                <el-table-column prop="opUser" label="检查人" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.opUser ? scope.row.opUser : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.opUser ? scope.row.opUser : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="remark" label="说明" width="200px" align="left">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.remark ? scope.row.remark : '—'" placement="top-start"  max-width='200'>
                                            <div style="width:180px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.remark ? scope.row.remark : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" align="center">
                                    <template slot-scope="scope">
                                        <el-button  @click.native.prevent="setEdit(scope.row,2)" type="text" size="small">编辑</el-button>
                                        <el-button  style="color:red" @click.native.prevent="removeRow(scope.row.resumeId)" type="text" size="small" >删除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div class="clearfix" v-show="tableList.length>0">
                                <div class="float-right">
                                    <Page v-if="resumeTotal" style="margin: 20px 0;text-align: center;" :current.sync="resumeCurrent" :total="resumeTotal" :page-size="resumePageSize" show-elevator show-total @on-change="resumePageChange"></Page>
                                </div>
                            </div>
                        </div>
                    </div>
                </TabPane>
                <TabPane label="机械设备使用" name="6">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>机械设备使用信息</span>
                            <i class="el-icon-circle-plus-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="setCommonFlag(3)"></i>
                        </h2>
                        <div class="table" style="width:96%;margin:20px auto;">
                            <el-table :data="tableList" style="width: 100%" :stripe='true' >
                                <el-table-column prop="name" label="使用名称" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.name ? scope.row.name : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.name ? scope.row.name : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="opUser" label="使用人" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.opUser ? scope.row.opUser : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.opUser ? scope.row.opUser : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="startTime" label="开始时间" align="center"></el-table-column>
                                <el-table-column prop="endTime" label="结束时间" align="center"></el-table-column>
                                <el-table-column prop="duration" label="使用时长（h）" align="center"></el-table-column>
                                <el-table-column prop="remark" label="说明" width="200px" align="left">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.remark ? scope.row.remark : '—'" placement="top-start"  max-width='200'>
                                            <div style="width:180px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.remark ? scope.row.remark : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" align="center" >
                                    <template slot-scope="scope">
                                        <el-button  @click.native.prevent="setEdit(scope.row,3)" type="text" size="small">编辑</el-button>
                                        <el-button  style="color:red" @click.native.prevent="removeRow(scope.row.resumeId)" type="text" size="small" >删除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div class="clearfix" v-show="tableList.length>0">
                                <div class="float-right">
                                    <Page v-if="resumeTotal" style="margin: 20px 0;text-align: center;" :current.sync="resumeCurrent" :total="resumeTotal" :page-size="resumePageSize" show-elevator show-total @on-change="resumePageChange"></Page>
                                </div>
                            </div>
                        </div>
                    </div>
                </TabPane>
                <TabPane label="机械设备维护" name="7">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>机械设备维护信息</span>
                            <i class="el-icon-circle-plus-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="setCommonFlag(4)"></i>
                        </h2>
                        <div class="table" style="width:96%;margin:20px auto;">
                            <el-table :data="tableList" style="width: 100%" :stripe='true' >
                                <el-table-column prop="name" label="维护名称" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.name ? scope.row.name : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.name ? scope.row.name : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="opUser" label="维护人" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.opUser ? scope.row.opUser : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.opUser ? scope.row.opUser : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="startTime" label="维护时间" align="center"></el-table-column>
                                <el-table-column prop="duration" label="维护时长（h）" align="center"></el-table-column>
                                <el-table-column prop="remark" label="维护结果" width="200px" align="left">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.remark ? scope.row.remark : '—'" placement="top-start"  max-width='200'>
                                            <div style="width:180px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.remark ? scope.row.remark : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" align="center" >
                                    <template slot-scope="scope">
                                        <el-button  @click.native.prevent="setEdit(scope.row,4)" type="text" size="small">编辑</el-button>
                                        <el-button  style="color:red" @click.native.prevent="removeRow(scope.row.resumeId)" type="text" size="small" >删除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div class="clearfix" v-show="tableList.length>0">
                                <div class="float-right">
                                    <Page v-if="resumeTotal" style="margin: 20px 0;text-align: center;" :current.sync="resumeCurrent" :total="resumeTotal" :page-size="resumePageSize" show-elevator show-total @on-change="resumePageChange"></Page>
                                </div>
                            </div>
                        </div>
                    </div>
                </TabPane>
                <TabPane label="机械设备拆卸" name="8">
                    <div class="msg">
                        <h2>
                            <em></em>
                            <span>机械设备拆卸信息</span>
                            <i class="el-icon-circle-plus-outline" style="font-size:24px;margin-left:20px;color:var(--themeColor);cursor: pointer" @click="setCommonFlag(5)"></i>
                        </h2>
                        <div class="table" style="width:96%;margin:20px auto;">
                            <el-table :data="tableList" style="width: 100%" :stripe='true' >
                                <el-table-column prop="name" label="拆卸名称" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.name ? scope.row.name : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.name ? scope.row.name : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="part" label="拆卸部位" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.part ? scope.row.part : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.part ? scope.row.part : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="startTime" label="拆卸时间" align="center"></el-table-column>
                                <el-table-column prop="opUser" label="拆卸人" align="center">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.opUser ? scope.row.opUser : '—'" placement="top"  max-width='200'>
                                            <div style="width:100px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.opUser ? scope.row.opUser : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column prop="remark" label="说明" width="200px" align="left">
                                    <template slot-scope="scope">
                                        <Tooltip  transfer :content="scope.row.remark ? scope.row.remark : '—'" placement="top-start"  max-width='200'>
                                            <div style="width:180px;overflow: hidden;text-overflow:ellipsis;white-space:nowrap;cursor: pointer;">{{scope.row.remark ? scope.row.remark : '—'}}</div>
                                        </Tooltip>
                                    </template>
                                </el-table-column>
                                <el-table-column label="操作" align="center" >
                                    <template slot-scope="scope">
                                        <el-button  @click.native.prevent="setEdit(scope.row,5)" type="text" size="small">编辑</el-button>
                                        <el-button  style="color:red" @click.native.prevent="removeRow(scope.row.resumeId)" type="text" size="small" >删除</el-button>
                                    </template>
                                </el-table-column>
                            </el-table>
                            <div class="clearfix" v-show="tableList.length>0">
                                <div class="float-right">
                                    <Page v-if="resumeTotal" style="margin: 20px 0;text-align: center;" :current.sync="resumeCurrent" :total="resumeTotal" :page-size="resumePageSize" show-elevator show-total @on-change="resumePageChange"></Page>
                                </div>
                            </div>
                        </div>
                    </div>
                </TabPane>
            </Tabs>
            <div slot="footer">
                <el-button @click="cancel(4)" type="type" size="small" plain v-if="!isAdd&&detailActiveName==1">取消</el-button>
                <el-button @click="submitAll" type="primary" size="small" plain v-preventReClick="1500" v-if="!isAdd&&detailActiveName==1">保存</el-button>
            </div>
        </Modal>
        <fseModal :commonModal="commonFlag" :tabIndex="tabIndex" :editFlag="editFlag" :editData="editData" :commonTitle="commonTitle" @handleClose="handleClose" @handleSubmit="handleSubmit" ></fseModal>
        <delModal :delModal="delModal" :delId="delId" :delContent="delContent" :setDelFn="setResumeDel"  @handleDelClose="handleDelClose" @handleDelSubmit="handleDelSubmit" ></delModal>
    </div>
</template>
<script>

import moment from 'moment';
import {
    getCraneList,
    getCraneAdd,
    getCraneEdit,
    getCraneDel,
    getCraneBind,
    getCraneUnbind,
    getCraneDetails,
    getCraneBindFvs,
    getHardwarePlatform,
    setResumeDel,
} from "@/api/api.js";
import fseModal from "./fseModal.vue";
import delModal from "../delModal";
import {initFvsList} from "@/mixins/fvs";
import {commonObj} from "./common";
export default {
    components: {fseModal,delModal},
    mixins:[initFvsList,commonObj],
    data() {
        return {
            headers: {
                Authorization:localStorage.getItem('COOKIE'),
            },
            setResumeDel,//删除函数
            fseType:1,//特种设备类型
            peoImg: require("./../../assets/images/common/noPeo.png"),
            current: 1,
            pageSize: 10,
            pageNum: 1,
            totalCount: "",
            deptId: "",
            deptName: "",
            keyWord: "",
            list: [],
            bindFlagList:[
                {
                    name:"未绑定",
                    id:0,
                },
                {
                    name:"已绑定",
                    id:1,
                }
            ],
            bindFlag:"",
            netState:"",
            netStateList:[
                {
                    name:"离线",
                    id:0,
                },
                {
                    name:"在线",
                    id:1,
                }
            ],
            updateModal: false,
            isAdd: true,
            updateId: "",
            deleteModal: false,
            unbindModal: false,
            unbindId: "",
            removeID: "",
            code: "",
            model: "",
            modelName: "",
            manufacturer: "",
            deliveryCode: "",
            deliveryDate: "",
            installUnit: "",
            propertyUnit: "",
            monitorNo: "",
            fileNo: "",
            fileDate: "",
            operatorList: [],
            bound_sn: "",
            boundId: "",
            craneId: "",
            detailsModal: false,
            details: {
                code: "",
                modelName: "",
                manufacturer: "",
                deliveryCode: "",
                deliveryDate: "",
                propertyUnit: "",
                monitorNo: "",
                fileNo: "",
                fileDate: "",
                bindFlag: "",
                operatorList: [],
                netState:"",
                installUnit:'',
            },
            length:16,
            detailActiveName:"1",
            detailsIndex: "",
            detailsRows: [],
            snFlag:0,
            sn:'',
            platformText:'',
            fvsFlag:false,
            platform:'', //硬件平台
            platformList:[],
            craneTypeList:[
                {
                    id:1,
                    name:"驾驶舱",
                    fvsDeviceName:'-',
                    fvsDeviceId:"",
                    type:[],
                },
                {
                    id:2,
                    name:"起重臂",
                    fvsDeviceName:'-',
                    fvsDeviceId:"",
                    type:[],
                },
                {
                    id:3,
                    name:"变幅小车",
                    fvsDeviceName:'-',
                    fvsDeviceId:"",
                    type:[],
                },
                {
                    id:4,
                    name:"平衡臂",
                    fvsDeviceName:'-',
                    fvsDeviceId:"",
                    type:[],
                }
            ]
        };
    },
    computed: {
        porjectObject() {
            return this.$store.state.porjectObject;
        }
    },
    watch: {
        porjectObject(val, oldVal) {
            if (val.deptId != oldVal.deptId) {
                this.deptId = val.deptId;
                this.deptName = val.deptName;
                this.pageNum = 1;
                this.keyWord = "";
                this.current = 1;
                this.getAllList();
            }
        },
        detailsModal(val){
            if(!val){
                this.fvsFlag = false
            }
        }
    },
    methods: {
        changeTime(time){
            this.fileDate=time
        },
        changeData(time){
            this.deliveryDate=time
        },
        getHardwarePlat(type) {
            let params = {
                deviceType: type
            };
            getHardwarePlatform(params)
                .then(res => {
                    if (res.code == 200) {
                        let list = res.data.list || [];
                        this.platformList = list;
                        if(this.platformList){
                            this.platform = this.platformList[0].platform
                        }
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        editFvs(){
            this.fvsFlag = true;
            if(this.detailActiveName == '4'){
                let obj = this.device_install;
                for (const key in obj) {
                    this.submit_device_install[key] = obj[key];
                }
            }
        },
        submitFvs(){
            let arr = [];
            this.craneTypeList.forEach(i=>{
                if(i.type.length >0) {
                    let obj = {
                        cranePart:i.id,
                        fvsDeviceId:i.type[1],
                        fvsDeviceName:'',
                    }
                    arr.push(obj);
                }
            })
            for(let i = 0; i <arr.length; i++) {
                for (let j = 0 ; j < this.fvsDeviceList.length; j++) {
                    if(arr[i].fvsDeviceId == this.fvsDeviceList[j].id) {
                        arr[i].fvsDeviceName = this.fvsDeviceList[j].name;
                    }
                }
            }
            for(let s = 0 ;s < arr.length;s++){
                for(let v = s+1;v <arr.length ;v++) {
                    if(arr[s].fvsDeviceId == arr[v].fvsDeviceId) {
                        this.$Modal.warning({
                            title: "提示",
                            content: "摄像头重复"
                        });
                        return;
                    }
                }
            }
            let params = {
                craneId:this.detailsRows[this.detailsIndex].craneId,
                fvsList:arr
            }
            getCraneBindFvs(params).then(res=>{
                if(res.code == 200) {
                    this.fvsFlag = false;
                    this.$Message.success("操作成功");
                    this.getDetails(this.detailsIndex,this.detailsRows,3)
                } else {
                   this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        edit_btn() {
            this.isAdd = false;
            this.updateRow(1,this.detailsIndex,this.detailsRows)
        },
        //获取塔机列表
        getAllList() {
            let params = {
                pageSize: this.pageSize,
                pageNum: this.pageNum,
                deptId: this.deptId,
                keyword: this.keyWord,
                bindFlag:this.bindFlag,
                netState:this.netState,
            };
            getCraneList(params)
                .then(res => {
                    if (res.code == 200) {
                        this.list = res.data.list;
                        this.detailsRows = res.data.list;
                        for (let i in this.list) {
                            let operEmpNameStr = [];
                            if(this.list[i].operatorList.length >0 ){
                                for (let j in this.list[i].operatorList) {
                                    operEmpNameStr.push(this.list[i].operatorList[j].name);
                                    this.list[i]["operatorName"] = operEmpNameStr.join(",");
                                }
                            } else {
                                 this.list[i]["operatorName"]  = "-"
                            }
                        }
                        this.totalCount = res.data.total;
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        pageChange(index) {
            this.pageNum = index;
            this.getAllList();
        },
        searchAll() {
            this.current = 1;
            this.pageNum = 1;
            this.getAllList();
        },
        clear() {
            this.current = 1;
            this.pageNum = 1;
            this.keyWord = "";
            this.netState = "";
            this.bindFlag = "";
            this.getAllList();
        },
        addEmp() {
            let obj ={};
            this.operatorList.push(obj)
        },
        // 删除操作手职位
        removeEmp(index) {
            this.operatorList.splice(index, 1);
        },
        //获取塔机详情
        getDetails(index, rows,type) {
            this.fseId = rows[index].craneId;
            this.isAdd = true;
            this.detailActiveName = String(type)
            this.detailsIndex = index;
            let params = {
                craneId:rows[index].craneId
            }
            getCraneDetails(params).then(res=>{
                if(res.code == 200) {
                    this.detailsModal = true;
                    this.details.code = res.data.code;
                    this.details.modelName = res.data.modelName;
                    this.details.manufacturer = res.data.manufacturer;
                    this.details.deliveryCode = res.data.deliveryCode;
                    this.details.installUnit = res.data.installUnit;
                    this.details.deliveryDate = res.data.deliveryDate;
                    this.details.propertyUnit = res.data.propertyUnit;
                    this.details.monitorNo = res.data.monitorNo;
                    this.details.fileNo = res.data.filingNo;
                    this.details.fileDate = res.data.filingDate;
                    this.details.bindFlag = res.data.bindFlag;
                    this.details.netState = res.data.netState;
                    this.details.operatorList = res.data.operatorList;
                    if(res.data.sn&&res.data.platform){
                        this.sn = res.data.sn;
                        this.platform = res.data.platform
                        let platformText = res.data.platform
                        let itemValue = this.platformList.find(item=>{
                            return item.platform == platformText
                        })
                        if(itemValue){
                            this.platformText = itemValue.name
                        }
                        this.snFlag = 3;
                    } else {
                        this.sn = "-";
                        this.platformText = "-"
                        this.snFlag = 1;
                    }
                    this.craneTypeList.forEach(i=>{
                        i.fvsDeviceId = "";
                        i.fvsDeviceName = "-"
                    })
                    this.craneTypeList.forEach(i=>{
                        i.type = [];
                        i.fvsDeviceId ="";
                        i.fvsDeviceName = "-";
                    })
                    for( let i = 0; i < res.data.fvsList.length; i++ ) {
                        for(let j = 0; j < this.craneTypeList.length; j++) {
                            if(res.data.fvsList[i].cranePart == this.craneTypeList[j].id) {
                                this.craneTypeList[j].fvsDeviceId = res.data.fvsList[i].fvsDeviceId;
                                this.craneTypeList[j].fvsDeviceName = res.data.fvsList[i].fvsDeviceName;
                            }
                        }
                    }
                    for(let i = 0 ; i <this.fvsDeviceList.length; i++) {
                        for(let j = 0 ; j < this.craneTypeList.length; j++) {
                            if(this.fvsDeviceList[i].id == this.craneTypeList[j].fvsDeviceId) {
                                this.craneTypeList[j].type = [this.fvsDeviceList[i].groupId, this.fvsDeviceList[i].id];
                                this.craneTypeList[j].fvsDeviceName = this.fvsDeviceList[i].groupName +"/" +this.fvsDeviceList[i].name;
                            }
                        }
                    }
                } else {
                    this.$Message.warning(res.msg);
                }
            }).catch(error=>{
                console.log(error)
            })
        },
        updateRow(type, index, rows){
            if (type == 0) {
                this.isAdd = true;
                this.code = "";
                this.model = "";
                this.manufacturer = "";
                this.deliveryCode = "";
                this.installUnit = "";
                this.deliveryDate = "";
                this.propertyUnit = "";
                this.monitorNo = "";
                this.fileNo = "";
                this.fileDate = "";
                this.operatorList = [];
                this.updateModal = true;
            } else if (type == 1) {
                this.isAdd = false;
                this.code = rows[index].code;
                this.craneId = rows[index].craneId;
                this.model = rows[index].modelName;
                this.manufacturer = rows[index].manufacturer;
                this.deliveryCode = rows[index].deliveryCode;
                this.installUnit = rows[index].installUnit;
                this.deliveryDate = rows[index].deliveryDate;
                this.propertyUnit = rows[index].propertyUnit;
                this.monitorNo = rows[index].monitorNo;
                this.fileNo = rows[index].filingNo;
                this.fileDate = rows[index].filingDate;
                this.operatorList = rows[index].operatorList;
            }
        },
        submitAll() {
            if (this.code == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "设备编号不能为空"
                });
                return;
            }
            if (this.operatorList.length > 0) {
                for (let i in this.operatorList) {
                    if ( this.operatorList[i].name == "" || this.operatorList[i].cert == "" || this.operatorList[i].name == undefined || this.operatorList[i].cert == undefined) {
                        this.$Modal.warning({
                            title: "您有必填字段",
                            content: "操作手姓名或操作手证书不能为空"
                        });
                        return;
                    }
                    if (this.operatorList[i].phone != "") {
                        if (!/^1[3456789]\d{9}$/.test(this.operatorList[i].phone)) {
                            this.$Modal.warning({
                                title: "您有必填提示字段",
                                content: "请填写正确的操作手手机号"
                            });
                            return;
                        }
                    }
                }
            }
            let deliveryDate,filingDate;
            if(!this.deliveryDate || this.deliveryDate == "") {
                deliveryDate = ""
            } else{
                deliveryDate = moment(this.deliveryDate).format('YYYY-MM-DD')
            }
            if(!this.fileDate || this.fileDate == "") {
                filingDate = "";
            } else {
                filingDate = moment(this.fileDate).format('YYYY-MM-DD')
            }
            if (this.isAdd) {
                let params = {
                    deptId: this.deptId,
                    deptName: this.deptName,
                    code: this.code,
                    modelName: this.model,
                    manufacturer: this.manufacturer,
                    deliveryCode: this.deliveryCode,
                    installUnit: this.installUnit,
                    deliveryDate: deliveryDate,
                    propertyUnit: this.propertyUnit,
                    monitorNo: this.monitorNo,
                    filingNo: this.fileNo,
                    filingDate: filingDate,
                    operatorList: this.operatorList
                };
                getCraneAdd(params)
                    .then(res => {
                        if (res.code == 200) {
                            this.success();
                        } else {
                            this.$Message.warning(res.msg);
                        }
                    })
                    .catch(error => {
                        console.log(error);
                    });
            } else {
                let params = {
                    craneId: this.craneId,
                    code: this.code,
                    modelName: this.model,
                    manufacturer: this.manufacturer,
                    deliveryCode: this.deliveryCode,
                    installUnit: this.installUnit,
                    deliveryDate: deliveryDate,
                    propertyUnit: this.propertyUnit,
                    monitorNo: this.monitorNo,
                    filingNo: this.fileNo,
                    filingDate: filingDate,
                    operatorList: this.operatorList,
                    deptId:this.deptId,
                };
                getCraneEdit(params)
                    .then(res => {
                        if (res.code == 200) {
                            this.success();
                        } else {
                            this.$Message.warning(res.msg);
                        }
                    })
                    .catch(error => {
                        console.log(error);
                    });
            }
        },
        success() {
            this.$Message.success("操作成功");
            this.pageNum = this.isAdd ? 1 : this.pageNum;
            this.current = this.isAdd ? 1 : this.current;
            if (this.isAdd) {
                this.updateModal = false;
            } else {
                this.isAdd = !this.isAdd;
                this.getDetails(this.detailsIndex, this.detailsRows,1);
            }
            this.keyWord = "";
            this.getAllList();
        },
        boundRow() {
            this.bound_sn = "";
            this.snFlag = 2
            this.boundId = this.detailsRows[this.detailsIndex].craneId;
        },
        boundSumbit() {
            if (this.bound_sn == "") {
                this.$Modal.warning({
                    title: "您有必填字段",
                    content: "请输入设备SN码"
                });
                return;
            }
            let params = {
                craneId: this.boundId,
                sn: this.bound_sn,
                platform:this.platform
            };
            getCraneBind(params)
                .then(res => {
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.getDetails(this.detailsIndex,this.detailsRows,2);
                        this.getAllList();
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        remove(index, rows) {
            this.removeID = rows[index].craneId;
            this.deleteModal = true;
        },
        deteleRow() {
            getCraneDel(this.removeID)
                .then(res => {
                    if (res.code == 200) {
                        this.deleteModal = false;
                        this.$Message.success("操作成功");
                        this.getAllList();
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        unbindRow() {
            this.unbindId = this.detailsRows[this.detailsIndex].craneId;
            this.unbindModal = true;
        },
        unbind() {
            getCraneUnbind(this.unbindId)
                .then(res => {
                    if (res.code == 200) {
                        this.$Message.success("操作成功");
                        this.unbindModal = false;
                        this.getDetails(this.detailsIndex,this.detailsRows,2);
                        this.getAllList();
                    } else {
                        this.$Message.warning(res.msg);
                    }
                })
                .catch(error => {
                    console.log(error);
                });
        },
        cancel(type) {
            if (type == 0) {
                this.updateModal = false;
            } else if (type == 1) {
                this.deleteModal = false;
            }  else if (type == 3) {
                this.unbindModal = false;
            } else if(type == 4) {
                this.isAdd = true;
                this.getDetails(this.detailsIndex,this.detailsRows,1)
            } else if(type == 5) {
                this.snFlag = 1;
            } else if (type == 6) {
                this.fvsFlag = false;
                this.getDetails(this.detailsIndex,this.detailsRows,3)
            }else if (type == 10) {
                this.fvsFlag = false;
            }
        }
    },
    mounted() {
        this.deptId = this.$store.state.porjectObject.deptId;
        this.deptName = this.$store.state.porjectObject.name;
        this.getAllList();
        this.getFvsList()
        this.getHardwarePlat(6)
    }
};
</script>

<style scoped lang="less">
@import "./../../assets/style/slider.less";
@import "./../../assets/style/fse_msg.less";
@import "./../../assets/style/themeBase.less";
</style>
